<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <meta name="author" content="Steven Watson">
  <link rel="shortcut icon" href="../../img/favicon.ico">
  <title>Basics - Chez-SDL</title>
  <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>

  <link rel="stylesheet" href="../../css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../css/theme_extra.css" type="text/css" />
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
  
  <script>
    // Current page data
    var mkdocs_page_name = "Basics";
    var mkdocs_page_input_path = "ref/basics.md";
    var mkdocs_page_url = null;
  </script>
  
  <script src="../../js/jquery-2.1.1.min.js" defer></script>
  <script src="../../js/modernizr-2.8.3.min.js" defer></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script> 
  
</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
      <div class="wy-side-nav-search">
        <a href="../.." class="icon icon-home"> Chez-SDL</a>
        <div role="search">
  <form id ="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
  </form>
</div>
      </div>

      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
	<ul class="current">
	  
          
            <li class="toctree-l1">
		
    <a class="" href="../..">Getting Started</a>
	    </li>
          
            <li class="toctree-l1">
		
    <a class="" href="../../sdl/">Overview of SDL 2</a>
	    </li>
          
            <li class="toctree-l1">
		
    <span class="caption-text">Tutorials</span>
    <ul class="subnav">
                <li class="">
                    
    <a class="" href="../../tuts/events/">Handling Events</a>
                </li>
                <li class="">
                    
    <a class="" href="../../tuts/renderer/">Renderer Basics</a>
                </li>
                <li class="">
                    
    <a class="" href="../../tuts/advanced-renderer/">Renderer Techniques</a>
                </li>
                <li class="">
                    
    <a class="" href="../../tuts/tetris/">Complete Example: Tetris</a>
                </li>
    </ul>
	    </li>
          
            <li class="toctree-l1">
		
    <span class="caption-text">Reference</span>
    <ul class="subnav">
                <li class=" current">
                    
    <a class="current" href="./">Basics</a>
    <ul class="subnav">
            
    <li class="toctree-l3"><a href="#initialization-and-shutdown">Initialization and Shutdown</a></li>
    

    <li class="toctree-l3"><a href="#configuration-variables">Configuration Variables</a></li>
    

    <li class="toctree-l3"><a href="#error-handling">Error Handling</a></li>
    

    <li class="toctree-l3"><a href="#querying-sdl-version">Querying SDL Version</a></li>
    

    </ul>
                </li>
                <li class="">
                    
    <a class="" href="../video/">Video</a>
                </li>
                <li class="">
                    
    <a class="" href="../audio/">Audio</a>
                </li>
                <li class="">
                    
    <a class="" href="../events/">Events</a>
                </li>
                <li class="">
                    
    <a class="" href="../inputs/">Inputs</a>
                </li>
                <li class="">
                    
    <a class="" href="../force/">Force Feedback</a>
                </li>
                <li class="">
                    
    <a class="" href="../power/">Power Management</a>
                </li>
                <li class="">
                    
    <a class="" href="../timers/">Timers</a>
                </li>
                <li class="">
                    
    <a class="" href="../values/">Values</a>
                </li>
                <li class="">
                    
    <a class="" href="../data/">Data Objects</a>
                </li>
    </ul>
	    </li>
          
        </ul>
      </div>
      &nbsp;
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../..">Chez-SDL</a>
      </nav>

      
      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../..">Docs</a> &raquo;</li>
    
      
        
          <li>Reference &raquo;</li>
        
      
    
    <li>Basics</li>
    <li class="wy-breadcrumbs-aside">
      
        <a href="https://github.com/steven741/chez-sdl/edit/master/docs/ref/basics.md"
          class="icon icon-github"> Edit on GitHub</a>
      
    </li>
  </ul>
  <hr/>
</div>
          <div role="main">
            <div class="section">
              
                <h1 id="initialization-and-shutdown">Initialization and Shutdown</h1>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-init</strong> <em>flags...</em>) → number</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>flags</em></strong> : One or more <a href="../values/#initialize-flags">flags</a>.</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>0 on proper startup or a negative number on error.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_Init</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_Init">SDL Wiki</a></p>
</blockquote>
<p>Examples:</p>
<pre><code class="scheme">(sdl-init
  SDL-INIT-EVERYTHING)
</code></pre>

<pre><code class="scheme">(sdl-init SDL-INIT-VIDEO
          SDL-INIT-AUDIO
          SDL-INIT-JOYSTICK)
</code></pre>

<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-init-sub-system</strong> <em>flags...</em>) → number</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>flags</em></strong> : One or more <a href="../values/#initialize-flags">flags</a>.</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>0 on proper startup or a negative number on error.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_InitSubSystem</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_InitSubSystem">SDL Wiki</a></p>
</blockquote>
<p>Examples:</p>
<pre><code class="scheme">(sdl-init-sub-system
  SDL-INIT-EVERYTHING)
</code></pre>

<pre><code class="scheme">(sdl-init-sub-system SDL-INIT-VIDEO
                     SDL-INIT-AUDIO
                     SDL-INIT-JOYSTICK)
</code></pre>

<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-quit</strong>) → void</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_Quit</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_Quit">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-quit-sub-system</strong> <em>flags...</em>) → void</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>flags</em></strong> : One or more <a href="../values/#initialize-flags">flags</a>.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_QuitSubSystem</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_QuitSubSystem">SDL Wiki</a></p>
</blockquote>
<p>Examples:</p>
<pre><code class="scheme">(sdl-quit-sub-system
  SDL-INIT-EVERYTHING)
</code></pre>

<pre><code class="scheme">(sdl-quit-sub-system SDL-INIT-VIDEO
                     SDL-INIT-AUDIO
                     SDL-INIT-JOYSTICK)
</code></pre>

<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-set-main-ready!</strong>) → void</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_SetMainReady</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_SetMainReady">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-init?</strong> <em>flags...</em>) → boolean</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>flags</em></strong> : One or more <a href="../values/#initialize-flags">flags</a>.</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p><code>#t</code> if systems were initialized and <code>#f</code> otherwise.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_WasInit</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_WasInit">SDL Wiki</a></p>
</blockquote>
<p>Examples:</p>
<pre><code class="scheme">(if (sdl-init? SDL-INIT-EVERYTHING)
    &lt;everything-was-initialized&gt;
    &lt;noting-was-initialized&gt;)
</code></pre>

<pre><code class="scheme">(if (sdl-init? SDL-INIT-VIDEO
               SDL-INIT-AUDIO
               SDL-INIT-JOYSTICK)
    &lt;systems-were-initialized&gt;
    &lt;systems-were-not-initialized&gt;)
</code></pre>

<h1 id="configuration-variables">Configuration Variables</h1>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-clear-hints!</strong>) → void</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_ClearHints</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_ClearHints">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-get-hint</strong> <em>name</em>) → string</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>name</em></strong> : A string. Name of the <a href="../values/#hints">hint.</a></p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>Returns the string value of a hint.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_GetHint</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_GetHint">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-get-hint-boolean</strong> <em>name</em> <em>default</em>) → boolean</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>name</em></strong> : A string. Name of the <a href="../values/#hints">hint.</a></p>
<p><strong><em>default</em></strong> : A boolean. Return value if hint not found.</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>The setting of the hint or, <strong><em>default</em></strong> if the hint isn't applicable to the system.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_GetHintBoolean</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_GetHintBoolean">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-set-hint!</strong> <em>name</em> <em>value</em>) → boolean</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>name</em></strong> : A string. Name of the <a href="../values/#hints">hint.</a></p>
<p><strong><em>value</em></strong> : A string. Value to set hint.</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p><code>#t</code> if hint was set or <code>#f</code> otherwise.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_SetHint</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_SetHint">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-set-hint-w/-priority!</strong> <em>name</em> <em>value</em> <em>priority</em>) → boolean</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>name</em></strong> : A string. Name of the <a href="../values/#hints">hint.</a></p>
<p><strong><em>value</em></strong> : A string. Value to set hint.</p>
<table>
<thead>
<tr>
<th align="left"><em>priority</em></th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">SDL-HINT-DEFAULT</td>
</tr>
<tr>
<td align="left">SDL-HINT-NORMAL</td>
</tr>
<tr>
<td align="left">SDL-HINT-OVERRIDE</td>
</tr>
</tbody>
</table>
</blockquote>
<p>Returns:</p>
<blockquote>
<p><code>#t</code> if hint was set or <code>#f</code> otherwise.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_SetHintWithPriority</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_SetHintWithPriority">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-make-hint-callback</strong> <em>procedure</em>) → hint-callback</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>procedure</em></strong> : A procedure of 3 arguments.</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>A callback that can be used with <code>sdl-add-hint-callback!</code> and <code>sdl-del-hint-callback!</code>.</p>
</blockquote>
<p>Examples:</p>
<pre><code class="scheme">(define my-hint-callback
    (sdl-make-hint-callback
     (lambda (name old-val new-val)
       (printf &quot;~s~n~d~n~d~n&quot; name old-val new-val))))
</code></pre>

<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-add-hint-callback!</strong> <em>name</em> <em>callback</em>) → void</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>name</em></strong> : A string. Name of the <a href="../values/#hints">hint.</a></p>
<p><strong><em>callback</em></strong> : A callback made with <code>sdl-make-hint-callback</code>.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_AddHintCallback</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_AddHintCallback">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-del-hint-callback!</strong> <em>name</em> <em>callback</em>) → void</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>name</em></strong> : A string. Name of the <a href="../values/#hints">hint.</a></p>
<p><strong><em>callback</em></strong> : A callback made with <code>sdl-make-hint-callback</code>.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_DelHintCallback</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_DelHintCallback">SDL Wiki</a></p>
</blockquote>
<h1 id="error-handling">Error Handling</h1>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-clear-error!</strong>) → void</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_ClearError</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_ClearError">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-get-error</strong>) → string</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>A message describing an error that has occured.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_GetError</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_GetError">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-set-error!</strong> <em>msg</em>) → number</p>
</blockquote>
<p>Parameters:</p>
<blockquote>
<p><strong><em>msg</em></strong> : A string.</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>Always returns <code>-1</code>.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_SetError</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_SetError">SDL Wiki</a></p>
</blockquote>
<h1 id="querying-sdl-version">Querying SDL Version</h1>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-get-version</strong>) → list</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>A list of 3 numbers. (major minor patch)</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_GetVersion</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_GetVersion">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-get-revision</strong>) → string</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>A string identifying the version of SDL being used.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_GetRevision</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_GetRevision">SDL Wiki</a></p>
</blockquote>
<hr />
<p>Procedure:</p>
<blockquote>
<p>(<strong>sdl-get-revision-num</strong>) → number</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>A number identifying the version of SDL being used.</p>
</blockquote>
<p>C Function Name:</p>
<blockquote>
<p><code>SDL_GetRevisionNumber</code></p>
</blockquote>
<p>Other Docs:</p>
<blockquote>
<p><a href="https://wiki.libsdl.org/SDL_GetRevisionNumber">SDL Wiki</a></p>
</blockquote>
              
            </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../video/" class="btn btn-neutral float-right" title="Video">Next <span class="icon icon-circle-arrow-right"></span></a>
      
      
        <a href="../../tuts/tetris/" class="btn btn-neutral" title="Complete Example: Tetris"><span class="icon icon-circle-arrow-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <!-- Copyright etc -->
    
      <p><a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/80x15.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</p>
    
  </div>

  Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
      
        </div>
      </div>

    </section>

  </div>

  <div class="rst-versions" role="note" style="cursor: pointer">
    <span class="rst-current-version" data-toggle="rst-current-version">
      
          <a href="https://github.com/steven741/chez-sdl/" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a>
      
      
        <span><a href="../../tuts/tetris/" style="color: #fcfcfc;">&laquo; Previous</a></span>
      
      
        <span style="margin-left: 15px"><a href="../video/" style="color: #fcfcfc">Next &raquo;</a></span>
      
    </span>
</div>
    <script>var base_url = '../..';</script>
    <script src="../../js/theme.js" defer></script>
      <script src="../../search/main.js" defer></script>

</body>
</html>
